package com.sxjh.controller.scalereport;

import cn.hutool.extra.cglib.CglibUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxjh.common.BaseController;
import com.sxjh.common.Result;
import com.sxjh.config.Authorization;
import com.sxjh.config.ExcelCacheConfig;
import com.sxjh.entity.ExcelEntity;
import com.sxjh.entity.Materials;
import com.sxjh.entity.param.Finance4ListParam;
import com.sxjh.entity.param.Finance6ListParam;
import com.sxjh.entity.param.ScaleReportParam;
import com.sxjh.entity.result.Finance4KhMxResult;
import com.sxjh.entity.result.MaterialListResult;
import com.sxjh.entity.result.MethylAlcoholListResult;
import com.sxjh.entity.result.ScaleReportResult;
import com.sxjh.service.FinanceService;
import com.sxjh.service.MaterialsService;
import com.sxjh.service.scalereport.ScaleReportService;
import com.sxjh.uitl.PageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/scaler/report")
@Api(tags = "磅单报表")
public class ScaleReportController extends BaseController {

  @Autowired
  private ScaleReportService scaleReportService;

  @ApiOperation("焦炭销售磅单")
  @GetMapping("/jt/xs/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> jtXsBd(@Validated ScaleReportParam param) {
    param.setCategoryId(3);
    return ok(scaleReportService.getScaleReport(param));
  }

  @ApiOperation("焦炭销售磅单")
  @GetMapping("/new/bd/test")
//  @Authorization("cb.finance.list")
  Result<List<ScaleReportResult>> newBdTest(@Validated ScaleReportParam param) {
    param.setCategoryId(3);
    return ok(scaleReportService.getScaleReport2(param));
  }

  @ApiOperation("焦炭销售磅单")
  @GetMapping("/new/fy/bd/test")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> newFyBdTest(@Validated ScaleReportParam param) {
    param.setCategoryId(3);
    return ok(scaleReportService.getScaleReport3(param));
  }

  @ApiOperation("甲醇销售磅单")
  @GetMapping("/jc/xs/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> jcXsBd(@Validated ScaleReportParam param) {
    param.setCategoryId(4);
    return ok(scaleReportService.getScaleReport(param));
  }
  @ApiOperation("焦油加工厂销售磅单")
  @GetMapping("/jyjgc/xs/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> jyjgcXsBd(@Validated ScaleReportParam param) {
    param.setCategoryId(5);
    return ok(scaleReportService.getScaleReport(param));
  }
  @ApiOperation("苯精制销售磅单")
  @GetMapping("/bjz/xs/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> bjzXsBd(@Validated ScaleReportParam param) {
    param.setCategoryId(6);
    return ok(scaleReportService.getScaleReport(param));
  }
  @ApiOperation("化产品回收厂销售磅单")
  @GetMapping("/hcphsc/xs/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> hcphscXsBd(@Validated ScaleReportParam param) {
    param.setCategoryId(7);
    return ok(scaleReportService.getScaleReport(param));
  }
  @ApiOperation("炭黑销售磅单")
  @GetMapping("/th/xs/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> thXsBd(@Validated ScaleReportParam param) {
    param.setCategoryId(8);
    return ok(scaleReportService.getScaleReport(param));
  }
  @ApiOperation("煤炭采购磅单")
  @GetMapping("/mt/cg/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> mtCgBd(@Validated ScaleReportParam param) {
    param.setCategoryId(9);
    return ok(scaleReportService.getScaleReport(param));
  }
  @ApiOperation("化工原料采购磅单")
  @GetMapping("/hgyl/cg/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> hgylCgBd(@Validated ScaleReportParam param) {
    param.setCategoryId(10);
    return ok(scaleReportService.getScaleReport(param));
  }
  @ApiOperation("化工辅料采购磅单")
  @GetMapping("/hgfl/cg/bd")
//  @Authorization("cb.finance.list")
  Result<PageUtil<ScaleReportResult>> hgflCgBd(@Validated ScaleReportParam param) {
    param.setCategoryId(11);
    return ok(scaleReportService.getScaleReport(param));
  }

  @ApiOperation("磅单报表导出")
  @GetMapping("/exportReportData")
  Result<String> exportReportData (@Validated ScaleReportParam param) {
    String id = ExcelCacheConfig.setParam(param, ExcelEntity.Type.BD);
    return ok(id);
  }

}
